public class Demo13 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            for(int i = 0; i < 5; i++) {
                System.out.println("hello t1");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t1 end");
        });

        Thread t2 = new Thread(() -> {
            for(int i = 0; i< 6; i++) {
                System.out.println("hello t2");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t2 end");
        });
        t1.start();
        t2.start();

        //main 函数等待t1 t2 最大时常  结束之后在进行main 函数
        t1.join();
        t2.join();
        System.out.println("main end");
    }
}
